﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Dqs_BLL;
using Model;
using Sunny.UI;

namespace Dqs_UI
{
	public partial class frmTeacher_Student : UIForm
	{
		public frmTeacher_Student()
		{
			InitializeComponent();
		}
		Student_BLL Student_BLL = new Student_BLL();

		private void frmTeacher_Student_Load(object sender, EventArgs e)
		{
			List<StudentInfo> list = Student_BLL.GetStudents();
			dgvStudentInfo.DataSource = list;
		}

		private void uiButton1_Click(object sender, EventArgs e)
		{
			int id = Convert.ToInt32(dgvStudentInfo.SelectedRows[0].Cells["Id"].Value);
			StudentInfo student = Student_BLL.GetStudents().FirstOrDefault(x => x.Id == id)!;
			student.AttendCount = Convert.ToInt32(dgvStudentInfo.SelectedRows[0].Cells["AttendCount"].Value);
			Student_BLL.UpdateStudentInfoById(student);

			frmTeacher_Student_Load(this, e);
		}

		private void dgvStudentInfo_CellContentClick(object sender, DataGridViewCellEventArgs e)
		{

		}
	}
}
